package com.ruoyi.web.controller.wq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wq.domain.WqUserQun;
import com.ruoyi.wq.service.IWqUserQunService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 我的群Controller
 * 
 * @author ruoyi
 * @date 2023-08-23
 */
@RestController
@RequestMapping("/wq/qunUser")
public class WqUserQunController extends BaseController {

    @Autowired
    private IWqUserQunService wqUserQunService;

    /**
     * 查询我的群列表
     */
    @PreAuthorize("@ss.hasPermi('wq:qunUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(WqUserQun wqUserQun)
    {
        startPage();
        List<WqUserQun> list = wqUserQunService.selectWqUserQunList(wqUserQun);
        return getDataTable(list);
    }

    /**
     * 导出我的群列表
     */
    @PreAuthorize("@ss.hasPermi('wq:qunUser:export')")
    @Log(title = "我的群", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WqUserQun wqUserQun)
    {
        List<WqUserQun> list = wqUserQunService.selectWqUserQunList(wqUserQun);
        ExcelUtil<WqUserQun> util = new ExcelUtil<WqUserQun>(WqUserQun.class);
        util.exportExcel(response, list, "我的群数据");
    }

    /**
     * 获取我的群详细信息
     */
    @PreAuthorize("@ss.hasPermi('wq:qunUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(wqUserQunService.selectWqUserQunById(id));
    }

    /**
     * 新增我的群
     */
    @PreAuthorize("@ss.hasPermi('wq:qunUser:add')")
    @Log(title = "我的群", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WqUserQun wqUserQun)
    {
        return toAjax(wqUserQunService.insertWqUserQun(wqUserQun));
    }

    /**
     * 修改我的群
     */
    @PreAuthorize("@ss.hasPermi('wq:qunUser:edit')")
    @Log(title = "我的群", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WqUserQun wqUserQun)
    {
        return toAjax(wqUserQunService.updateWqUserQun(wqUserQun));
    }

    /**
     * 删除我的群
     */
    @PreAuthorize("@ss.hasPermi('wq:qunUser:remove')")
    @Log(title = "我的群", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wqUserQunService.deleteWqUserQunByIds(ids));
    }
}
